use "C:\Province Database"
keep if country=="Indonesia"
collapse (sum) wpd,by(province mdate)
bysort mdate: egen twpd=total(wpd)
gen sw=100*wpd/twpd
bysort province: egen rm=rank(mdate)
save "C:\z1",replace
keep if rm==13
egen rprov=rank(sw),field
keep province rprov
sort province
save "C:\z2",replace

use "C:\z1"
sort province
merge province using "C:\z2"
drop _merge
keep if rprov<6
keep wpd province mdate
save "C:\z3",replace

gen prov1=word(province,1)
gen prov2=word(province,2)
gen prov=prov1+prov2

drop province prov1 prov2  
gen sw=wpd
drop wpd
reshape wide sw,i(mdate) j(prov) string

* swKalimantanBarat swKalimantanTengah swRiau swSumateraSelatan swSumateraUtara

label variable swKalimantanBarat "West Kalimantan"
label variable swKalimantanTengah "Central Kalimantan"
label variable swRiau "Riau"
label variable swSumateraSelatan "South Sumatra"
label variable swSumateraUtara "North Sumatra"

* egen rm=rank(mdate),field
* drop if rm<14

drop if swRiau==0

line sw* mdate, lcolor(black red gren blue orange) lwidth(medthick) lpattern(dash_dot longdash solid shortdash dash) xtitle("") ysize(3) xsize(4.5) xtick(#5) xlabel(#5) legend(size(medium) rows(5))
graph export "C:\Indo Provs.wmf", replace
